<?php
/**
 * 语言包管理
 *
 * @package         YDCMS
 * @author          QQ:644157559 <644157559@qq.com>
 * @version         $Id: LanguageLogic.class.php v1.0 2014-06-23 17:27:03 $
 */
namespace Admin\Logic;
class LanguageLogic extends CommonLogic{
    
    /**
     * 生成新添加语言包文件
     * @param type $nid
     * @return boolean
     */
    public function genLangFile($nid) {
        $lang_file = LANG_PATH . $nid . ".php";
        if(file_exists($lang_file)){
            return false;
        }
        $header = "/**\r\n* YDCMS {$nid} language package\r\n*/";
        $value = array();
        fast_cache($nid, $value, LANG_PATH, $header);
    }
    
    /**
     * 删除语言包
     * @param type $nid
     * @return boolean
     */
    public function delLangFile($nid) {
        $lang_file = LANG_PATH . $nid . ".php";
        if(!file_exists($lang_file)){
            return false;
        }
        fast_cache($nid, NULL, LANG_PATH);
    }
    /**
     * 生成允许切换的语言列表
     */
    public function genLangList() {
        $tmp_lang_list = D("Language", "Service")->getAll(array("status" => 1), "nid");
        $lang_list = array();
        foreach ($tmp_lang_list as $key => $val) {
           $lang_list[] =  $val['nid'];
        }
        $web_conf = fast_cache("web_config", '', YDCMS_DATA);
        $web_conf["LANG_LIST"] = implode(",", $lang_list);
        fast_cache("web_config", $web_conf, YDCMS_DATA);
    }
}
